package com.example.service.impl;

import com.example.common.result.PageResult;
import com.example.entity.dto.IHeadCheckPageDto;
import com.example.entity.hz.IHead;
import com.example.entity.vo.CheckVo;
import com.example.entity.vo.IHeadVo;
import com.example.entity.yifei.Inspectionng;
import com.example.mapper.IHeadMapper;
import com.example.mapper.InspectionngMapper;
import com.example.service.IHeadService;
import com.example.service.InspectionngService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author Lan
 * @since 2024-09-27
 */
@Service
public class InspectionngServiceImpl extends ServiceImpl<InspectionngMapper, Inspectionng> implements InspectionngService {

    @Autowired
    private InspectionngMapper inspectionngMapper;
    @Autowired
    private IHeadMapper iHeadMapper;

    /**
     * 获取检查数量，合格率，不合格率
     * @return
     */
    public CheckVo getCheck() {
        CheckVo checkVo = iHeadMapper.getCheck();
        return checkVo;
    }

    /**
     * 获取所有未检查的数据
     * @param checkpageDto
     * @return
     */
    @Override
    public PageResult getCheckByStatus(IHeadCheckPageDto checkpageDto) {
        PageHelper.startPage(checkpageDto.getPage(),checkpageDto.getPagesize());

        Page<List<IHeadVo>> page= (Page)iHeadMapper.getPageByStatus(checkpageDto);
        long total = page.getTotal();
        PageResult pageResult = new PageResult();
        pageResult.setTotal(total);
        pageResult.setRecords(page.getResult());
        return pageResult;
    }
}
